package com.edu.exam.entity.quality.monitoring;

import com.edu.exam.enums.quality.monitoring.AssignmentType;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.time.LocalDateTime;

/**
 * 分配类型配置实体类
 *
 * 根据E-06-01任务分配子模块设计实现
 * 对应assignment_type_config数据表，用于存储不同分配类型的配置参数
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class AssignmentTypeConfig {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Enumerated(EnumType.STRING)
    @Column(name = "assignment_type", length = 50, unique = true, nullable = false)
    private AssignmentType assignmentType;

    @Column(name = "type_name", length = 100, nullable = false)
    private String typeName;

    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    @Column(name = "config_json", columnDefinition = "TEXT", nullable = false)
    private String configJson; // 配置参数（JSON格式）

    @Column(name = "validation_rules", columnDefinition = "TEXT")
    private String validationRules; // 验证规则（JSON格式）

    @Column(name = "enabled", nullable = false)
    private Boolean enabled;

    @Column(name = "max_graders")
    private Integer maxGraders;

    @Column(name = "min_graders")
    private Integer minGraders;

    @Column(name = "default_config", columnDefinition = "TEXT")
    private String defaultConfig; // 默认配置（JSON格式）

    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Column(name = "update_time", nullable = false)
    private LocalDateTime updatedTime;

    @Column(name = "created_by", length = 50)
    private String createdBy;

    @Column(name = "updated_by", length = 50)
    private String updatedBy;

    // 扩展字段
    @Column(name = "category", length = 50)
    private String category; // 配置分类

    @Column(name = "priority")
    private Integer priority; // 优先级

    @Column(name = "version", length = 20)
    private String version; // 配置版本

    @Column(name = "compatibility_version", length = 20)
    private String compatibilityVersion; // 兼容版本

    @Column(name = "usage_count")
    private Long usageCount; // 使用次数

    @Column(name = "last_used_time")
    private LocalDateTime lastUsedTime; // 最后使用时间

    @Column(name = "success_rate", precision = 5, scale = 2)
    private Double successRate; // 成功率

    @Column(name = "average_efficiency", precision = 5, scale = 2)
    private Double averageEfficiency; // 平均效率评分

    @Column(name = "error_rate", precision = 5, scale = 2)
    private Double errorRate; // 错误率

    @Column(name = "requires_approval")
    private Boolean requiresApproval; // 是否需要审批

    @Column(name = "approval_level", length = 20)
    private String approvalLevel; // 审批级别

    @Column(name = "auto_assignment_enabled")
    private Boolean autoAssignmentEnabled; // 是否启用自动分配

    @Column(name = "manual_override_allowed")
    private Boolean manualOverrideAllowed; // 是否允许手动覆盖

    @Column(name = "time_constraints", columnDefinition = "TEXT")
    private String timeConstraints; // 时间约束（JSON格式）

    @Column(name = "quality_requirements", columnDefinition = "TEXT")
    private String qualityRequirements; // 质量要求（JSON格式）

    @Column(name = "workload_limits", columnDefinition = "TEXT")
    private String workloadLimits; // 工作负载限制（JSON格式）

    @Column(name = "notification_settings", columnDefinition = "TEXT")
    private String notificationSettings; // 通知设置（JSON格式）

    @Column(name = "monitoring_settings", columnDefinition = "TEXT")
    private String monitoringSettings; // 监控设置（JSON格式）

    @Column(name = "backup_settings", columnDefinition = "TEXT")
    private String backupSettings; // 备份设置（JSON格式）

    @Column(name = "security_settings", columnDefinition = "TEXT")
    private String securitySettings; // 安全设置（JSON格式）

    @Column(name = "compliance_rules", columnDefinition = "TEXT")
    private String complianceRules; // 合规规则（JSON格式）

    @Column(name = "performance_metrics", columnDefinition = "TEXT")
    private String performanceMetrics; // 性能指标（JSON格式）

    @Column(name = "custom_attributes", columnDefinition = "TEXT")
    private String customAttributes; // 自定义属性（JSON格式）

    @Column(name = "deprecation_date")
    private LocalDateTime deprecationDate; // 弃用日期

    @Column(name = "sunset_date")
    private LocalDateTime sunsetDate; // 停用日期

    @Column(name = "notes", columnDefinition = "TEXT")
    private String notes; // 备注说明


}